package com.atguigu.spring.ioc.dao;

import com.atguigu.spring.ioc.bean.Dog;
import lombok.ToString;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

@ToString
@Repository
public class UserDao {
    Dog dog;

    // 构造器注入(Spring推荐)
    // 不提供无参构造器,Spring 会自动取容器里的相关bean
//    public UserDao(Dog dog2) {
//        this.dog = dog2;
//    }

    // setter方法注入
    @Qualifier(value = "dog3")
    @Autowired
    public void setDog(Dog dog2) {
        this.dog = dog2;
    }
}
